package com.mayikt;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Author: maplefire
 * @Description: NewScheduledThreadPoolTest
 * @Date: 2022/09/02 15:43
 */

public class NewScheduledThreadPoolTest {
    public static void main(String[] args) {
        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(3);
        for (int i = 0; i < 10; i++) {
            final int temp = i;
            executorService.schedule(new Runnable() {
                public void run() {
                    System.out.println(Thread.currentThread().getName() + "," + temp);
                }
            }, 3, TimeUnit.SECONDS);
        }
        System.out.println("等待3s后执行...");
    }
}
